package c16多线程;

/**
 * @author 炜sama
 * setPriority的位置随意，也就是说可以在start前后设置线程的优先级！
 */
public class 设置线程优先级 {

	public static void main(String[] args) throws InterruptedException {
		MyThread mth = new MyThread("高级线程");
		MyThread mtl = new MyThread("低级线程");

		mtl.setPriority(Thread.MIN_PRIORITY);
		mtl.start();
		Thread.sleep(1);
		mth.setPriority(Thread.MAX_PRIORITY);
		mth.start();
	}

}

class MyThread extends Thread {
	public MyThread() {
	}

	public MyThread(String name) {
		super(name);
	}

	@Override
	public void run() {
		for (int i = 0; i < 100; i++) {
			System.err.println(getName() + "的优先级为：" + getPriority() + "，循环变量：" + i);
		}
	}
}